<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>软件版本信息</title>
<t:base type="jquery,easyui,tools"></t:base>
</head>
<body style="overflow-y: auto" scroll="no">
<t:formvalid formid="formobj" layout="div" dialog="true"  action="sysVersionController.do?save" beforeSubmit="f_validate()">
	<input name="id" id="id" type="hidden" value="${version.id}">
	<input name="version" id="version" type="hidden" value="${version.version}">
	<fieldset class="step">
	<div class="form">
        <label class="Validform_label"> 版本号: </label>
        <input name="versionValid"  <c:if test="${version.id != null}">disabled="disabled" </c:if> value="0" onblur="f_validateVersion(this)" style="width:39px" class="inputxt">.
        <input name="versionValid" <c:if test="${version.id != null}">disabled="disabled" </c:if>  value="0" onblur="f_validateVersion(this)"  style="width:39px" class="inputxt">.
        <input name="versionValid" <c:if test="${version.id != null}">disabled="disabled" </c:if>  value="0" onblur="f_validateVersion(this)"  style="width:39px" class="inputxt">
        <%--<input name="versionValid" <c:if test="${version.id != null}">disabled="disabled" </c:if>  value="0" onblur="f_validateVersion(this)" style="width:25px"  class="inputxt">--%>
        <span class="Validform_checktip" id="versionValid">请按照1.1.1.1格式填写</span>
    </div>
	<div class="form">
        <label class="Validform_label"> 主版本: </label>
        <input name="masterVersion" <c:if test="${version.id != null}">disabled="disabled" </c:if> type="number"  class="easyui-numberbox"  min="1" precision="1"  style="height: 25px;width: 150px;" datatype="*" id="masterVersion" value="${version.masterVersion}">
        <span class="Validform_checktip">格式1.0</span>
    </div>
	<div class="form">
        <label class="Validform_label"> 下载地址: </label>
        <input name="downloadAddr" datatype="*" id="downloadAddr" value="${version.downloadAddr!=null?version.downloadAddr :'http://'}" class="inputxt">
        <span class="Validform_checktip">完整下载地址，格式以http://开头</span>
    </div>
	<div class="form">
        <label class="Validform_label"> 软件类型: </label>
        <t:dictSelect field="softType" id="softType" typeGroupCode="softType" defaultVal="${version.softType}"
                      hasLabel="false" extendJson="{datatype='*'}" >
        </t:dictSelect>
        <span class="Validform_checktip"></span>
    </div>
	<div class="form">
        <label class="Validform_label"> 系统类型: </label>

        <t:dictSelect field="type" id="type" typeGroupCode="appType" defaultVal="${version.type}"
                      hasLabel="false" extendJson="{datatype='*'}" >
        </t:dictSelect>

        <span class="Validform_checktip"></span>
    </div>
	<div class="form">
        <label class="Validform_label"> 是否发布: </label>

        <t:dictSelect field="isable" id="isable" typeGroupCode="isno" defaultVal="${version.isable}"
                      hasLabel="false" extendJson="{datatype='*'}" >
        </t:dictSelect>

        <span class="Validform_checktip"></span>
    </div>
	<div class="form">
        <label class="Validform_label"> 是否强制升级: </label>

        <t:dictSelect field="upgrade" id="upgrade" typeGroupCode="isno" defaultVal="${version.upgrade}"
                      hasLabel="false" extendJson="{datatype='*'}" >
        </t:dictSelect>

        <span class="Validform_checktip"></span>
    </div>
	<div class="form">
        <label class="Validform_label"> 更新内容: </label>

        <textarea class="inputxt" id="content" name="content" style="height: 100px;width: 500px;" rows="3">${version.content}</textarea>

        <span class="Validform_checktip"></span>
    </div>
	</fieldset>
</t:formvalid>

<script type="text/javascript">

    $(function(){

        var va = "${version.version}";
        if(va != ""){

            var vas = va.split(".");

            for(var i = 0; i < vas.length; i++){

                $("input[name='versionValid']").get(i).value = vas[i];

            }

        }

        $("input[name='versionValid']").keyup(f_versionValid);

    });

    function f_versionValid(obj){
        if(obj.keyCode == 190 || obj.keyCode == 110){

            $(this).val($(this).val().substr(0,$(this).val().length - 1))

            f_validateVersion(this);

        }
    }

    //验证
    function f_validateVersion(obj){

        var version = $(obj).val();

        if(!version){
            $(obj).val(0);

        }

        var boo = true;

        if((/\D/g.test(version))){
            $("#versionValid").html("版本格式必须为数字！");
            $("#versionValid").addClass("Validform_wrong");
            $(obj).addClass("Validform_error");
            boo = false;
        }else{
            $("#versionValid").html("通过信息验证！");
            $("#versionValid").removeClass("Validform_wrong");
            $(obj).removeClass("Validform_error");
            $("#versionValid").addClass("Validform_right");
            boo = true;
        }

        if(boo){
            $(this).next().focus();
        }else{
            $(this).focus();
        }

        return boo;

    }

    function f_validate(){

        var version = "";

        for(var i = 0; i < $("input[name='versionValid']").length; i++){

            var boo = f_validateVersion($("input[name='versionValid']").get(i));

            if(!boo){

                return false;
            }

            version += $("input[name='versionValid']").get(i).value;
            if(i < $("input[name='versionValid']").length - 1){
                version += ".";
            }
        }

        $("#version").val(version);
        return true;

    }

</script>
</body>
</html>
